home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / DBASE5 / CUA_SAMP.ZIP / MDADD.PRG < prev    next >
Text File  |  1994-10-12  |  4KB  |  103 lines

  1. *.............................................................................
  2. *
  3. *   Program Name: MDADD.PRG           Copyright: Borland International
  4. *   Date Created:  7 Apr 94            Language: dBASE 5.0
  5. *   Time Created: 16:20:07               Author: Borland dBASE R&D
  6. *   /brief/library.src
  7. *.............................................................................
  8.  
  9. *..........................................................................
  10. * Procedure Name:   MDAdd
  11. * Parameters:       None
  12. * Ext Memvars:      None
  13. * Description:      Adds a record to the end of the current table and sets
  14. *                   the record pointer to it.
  15. *..........................................................................
  16. PROCEDURE MDAdd
  17.     PRIVATE lVoid, oRef, oForm, Form, oF, oC
  18.  
  19.     #include "TalkOff.hdb"
  20.  
  21.     *------------------------------------------------------------------
  22.     *-- Get the object reference to the Form object.  Remember This. is
  23.     *-- the menu item.
  24.     *------------------------------------------------------------------
  25.     oForm = This.Form
  26.  
  27.     *---------------------------------------------------------------------
  28.     *-- Make sure this is a database form.  CurrMast will be set if it is.
  29.     *---------------------------------------------------------------------
  30.     IF oForm.ClassName = "FORM" .AND. TYPE( "oForm.CurrMast" ) = "C"
  31.  
  32.         *------------------------------------------------
  33.         *-- Need to commit the current record if modified
  34.         *------------------------------------------------
  35.         IF .NOT. SubmitFm( m->oForm )
  36.             #include "talkon.hdb"
  37.             RETURN
  38.         ENDIF
  39.  
  40.         *----------------------------------------------------------------
  41.         *-- Set the AddingRec flag for future handling of the Next record
  42.         *-- pushbutton.
  43.         *----------------------------------------------------------------
  44.         oForm.AddingRec = .T.
  45.  
  46.         *----------------------------
  47.         *-- Go to the end of the file
  48.         *----------------------------
  49.         GO BOTTOM
  50.         IF .NOT. EOF()
  51.             SKIP
  52.         ENDIF
  53.  
  54.         DO UpLook WITH m->oForm
  55.  
  56.         *-------------------------------------------------------------
  57.         *-- By doing a Refresh() here, the form values are blanked out
  58.         *-------------------------------------------------------------
  59.         lVoid = oForm.Refresh()
  60.  
  61.         *-------------------------------
  62.         *-- Check for any default values
  63.         *-------------------------------
  64.         IF TYPE( "oForm.HasDefVal" ) = "L" .AND. oForm.HasDefVal
  65.             Form = oForm                && Set Form. reference for DefValue
  66.             DO DefValue
  67.         ENDIF
  68.  
  69.         *------------------------------------------
  70.         *-- Check for need to update Detail regions
  71.         *------------------------------------------
  72.         IF TYPE( "oForm.DetExist" ) = "L" .AND. oForm.DetExist
  73.             DO UpDetail WITH m->oForm
  74.         ENDIF
  75.  
  76.         *-------------------------------
  77.         *-- Select the master alias back
  78.         *-------------------------------
  79.         SELECT ( oForm.CurrMast )
  80.  
  81.         *------------------------------------------
  82.         *-- Make sure focus goes to the first field
  83.         *------------------------------------------
  84.         oF = Form.First
  85.         oC = m->oF
  86.         DO WHILE .T.
  87.             IF .NOT. ( oC.ClassName $ "RECTANGLE,TEXT,PAGEBREAK" )
  88.                 lVoid = oC.SetFocus()
  89.                 EXIT
  90.             ENDIF
  91.             oC = oC.After
  92.             IF oC = m->oF
  93.                 EXIT
  94.             ENDIF
  95.         ENDDO
  96.  
  97.     ENDIF
  98.  
  99.     #include "TalkOn.hdb"
  100.  
  101. RETURN
  102.  
  103.